<template>
	<!-- 环境监控items -->
	<view class="container">
		<view class="environment-item" v-for="(item, index) in listData" :key="index">
			<!-- 左侧图片 -->
			<view class="item-img">
				<image :src="upperTempImg" v-if="item.type==1 && item.upper==1"></image>
				<image :src="commonTempImg" v-if="item.type==1 && item.upper==0"></image>
				<image :src="upperHumImg" v-if="item.type==2 && item.upper==1"></image>
				<image :src="commonTempImg" v-if="item.type==2 && item.upper==0"></image>
			</view>
			
			
			<!-- 中间描述 -->
			<view class="item-desc">
				<view class="item-title" :class='[item.upper==1 ? "upper" : ""]'>
					<text>{{item.name}}</text>
					<text>{{item.name}}</text>
					<text>{{item.number}}</text>
				</view>
				<view class="item-time">
					<text>更新于</text>
					{{item.time}}
				</view>
			</view>
			<!-- 右边箭头 -->
			<view class="item-arrow" @tap="toDetail(item)">
				<image :src="upperArrow" v-if="item.upper==1"></image>
				<image :src="arrow" v-else></image>
			</view>
		</view>

	</view>
</template>

<script>
	export default {
		props: {
			list: {
				type: Array,
				default () {
					return []
				}
			}

		},
		data() {
			return {
				listData: [],
				upperTempImg: '../../static/image/monitor/upperTemp.png',
				commonTempImg: '../../static/image/monitor/temp.png',
				upperHumImg: '../../static/image/monitor/upperHum.png',
				commonHumImg: '../../static/image/monitor/hum.png',
				upperArrow: '../../static/image/monitor/upperArrow.png',
				arrow: '../../static/image/monitor/arrow.png'

			}
		},
		watch: {
			list(newVal, oldVal) {
				this.listData = newVal
			}
		},
		created() {
			this.listData = this.list
		},
		methods: {
			// 
			toDetail(item){
				this.$emit('click', item)
			}
		}

	}
</script>

<style lang="scss">
	.container {

		.environment-item {
			display: flex;
			flex-direction: row;
			align-items: center;
			margin-bottom: 10rpx;
			height: 140rpx;
			background-color: #fff;
			padding-left: 24rpx;
			padding-right: 38rpx;

			.item-img {
				float: left;

				image {
					width: 100rpx;
					height: 100rpx;
				}
			}

			.item-desc {
				display: flex;
				flex-direction: column;
				float: left;
				width: 100%;
				margin: 0 73rpx 0 24rpx;

				.item-title {
					display: flex;
					flex-direction: row;
					justify-content: space-between;
					font-size: 32rpx;
					color: #666;
					margin-bottom: 12rpx;
				}

				.item-time {
					color: #999;
					font-size: 22rpx;

					text {
						// margin-right: ;
					}
				}

				.upper {
					color: #FF7547;
				}

			}

			.item-arrow {
				float: left;
				padding: 20rpx;
				image {
					width: 32rpx;
					height: 32rpx;
				}
			}
		}
	}
</style>
